﻿using MediatR;
using Traceability.App.Applications.Command.IMage;
using Traceability.Domain.Entity;
using Traceability.Domain.Repository;
using Traceability.Enum;

namespace Traceability.App.Applications.CommandHand.IMage
{
    public class GetImageCommadHand : IRequestHandler<GetImageCommad, ApiResult<List<ImageModel>>>
    {

        private readonly IBaseRepository<ImageModel> _image;

        public GetImageCommadHand(IBaseRepository<ImageModel> image)
        {
            _image = image;
        }

        public Task<ApiResult<List<ImageModel>>> Handle(GetImageCommad request, CancellationToken cancellationToken)
        {
            var result=new ApiResult<List<ImageModel>>();   
            var m = _image.GetAll().Where(x => x.Batch == request.Batch && x.Type == request.Type&&x.del==0).ToList();

            result.data=m;
            return Task.FromResult(result); 
            
            


        }
    }
}
